<?php
    $title = 'บริษัท แบคอัพ คอมมิวนิเคชั่นส์ แอนด์ เซอร์วิสเซส จำกัด';
    include('header.php');
    
    $name = '';
    $email = '';
    $phone = '';
    $subjectx = '';
    $msg = '';
    
    if(isset($_REQUEST['name'])){
	
	if($_REQUEST['name']==''){
	    alert('Please enter your name.');
	}else{
	    $name = $_REQUEST['name'];
	    $email = $_REQUEST['email'];
	    $phone = $_REQUEST['phone'];
	    $subjectx = $_REQUEST['subject'];
	    $msg = $_REQUEST['msg'];
	    
	    if($_REQUEST['email']==''){
		alert('Please enter your e-mail.');
	    }else{
		if($_REQUEST['phone']==''){
		    alert('Please enter your phone number.');
		}else{
		    if($_REQUEST['subject']==''){
			alert('Please enter subject.');
		    }else{
			if($_REQUEST['msg']==''){
			    alert('Please enter your message.');
			}else{
			    $html_mail =  '<strong>Name : </strong>'.$_REQUEST['name'];
			    $html_mail .=  '<br /><strong>E-mail : </strong>'.$_REQUEST['email'];
			    $html_mail .=  '<br /><strong>Phone : </strong>'.$_REQUEST['phone'];
			    $html_mail .=  '<br /><strong>Subject : </strong>'.$_REQUEST['subject'];
			    $html_mail .=  '<br /><strong>Message : </strong><br />'.$_REQUEST['msg'];
			    
			    $to      = CONTACT_EMAIL;
			    
			    $subject = 'Message from contact form';
			    $message = $html_mail;
		    
			    $headers  = 'MIME-Version: 1.0' . "\r\n";
			    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
			    $headers .= "From: $email" . "\r\n" .
				    "Reply-To: $email" . "\r\n" .
				    'X-Mailer: PHP/' . phpversion();
		    
			    $result = @mail($to, $subject, $message, $headers);
			    
			    if($result){
				alert('Email has been successfuly send.');
				$name = '';
				$email = '';
				$phone = '';
				$subjectx = '';
				$msg = '';
			    }else{
				alert('Can\'t send email, please try agarin later.,');
			    }
			}
		    }
		}
	    }
	}
    }
?>
            <div id="contact_left">
		<a href="images/map3.png" class="aColorBox"><img src="images/map.jpg" /></a>
		<h2><?php echo _l('Contact'); ?></h2>
		<p>
		   <?php echo _l('contact-us-address'); ?>
		</p>
	    </div>
	    <div id="contact_right">
		<h4><?php echo _l('Send and email. All fileds with an * are required.'); ?></h4>
		
		<form id="contact_frm" method="post" action="">
		    <div class="contact_input">
			<span>Name * :</span>
			<input type="text" name="name" id="c_name" value="<?php echo $name; ?>" />
		    </div>
		    <div class="contact_input">
			<span>E-mail * :</span>
			<input type="text" name="email" id="c_email" value="<?php echo $email; ?>" />
		    </div>
		    <div class="contact_input">
			<span>Phone * :</span>
			<input type="text" name="phone" id="c_phone" value="<?php echo $phone; ?>" />
		    </div>
		    <div class="contact_input">
			<span>Subject * :</span>
			<input type="text" name="subject" id="c_subject" value="<?php echo $subjectx; ?>" />
		    </div>
		    <div class="contact_input">
			<span>Message * :</span>
			<textarea name="msg" id="c_msg"><?php echo $msg; ?></textarea>
		    </div>
		</form>
		
		
		<div id="contact_frm_bt">
		    <a href="javascript:void(0)" title="Send">[ Send ]</a>
		</div>
	    </div>
	    <div class="clear">&nbsp;</div>
<?php
    include('footer.php');
?>
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script>
<link href="css/colorbox.css" rel="stylesheet" />
<script>
    $(document).ready(function(){
	$('#contact_frm_bt a').live('click',function(){
	    $('#contact_frm').submit();
	});
	
	$('.aColorBox').colorbox();
    });
</script>